package com.hnqcgczy.gp.db;

import java.sql.*;

public abstract class IConnection {
    /**
     * 打开数据库连接
     * @return
     * @throws SQLException
     */
    public  abstract  Connection getConnectionByMysql()throws SQLException;
    public abstract Connection getConnectionByOracle()throws  SQLException;


    /**
     * 释放资源
     * @param ps
     * @param statement
     * @param resultSet
     * @throws SQLException
     */
    public void closeAll (PreparedStatement ps,Statement statement,ResultSet resultSet){
        if (ps!=null){

            try {
                ps.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if (statement!=null){
            try {
                statement.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }

        }
        if (resultSet!=null){
            try {
                resultSet.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        /*if (resultSet!=null){
            resultSet.close();
        }
        if (statement!=null){
            statement.close();
        }*/
    }
}